package com.jh.paymentchannel.pojo.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * @author zhugu
 * @version 1.0
 * @Date 2019/1/3 17:50
 */
public enum PayType {

    TRADE("1", "交易"),

    WITHDRAW("2", "代还"),

    WITHDRAW_("3", "提现"),

    ;

    final String value;
    final String desc;

    PayType(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public static PayType of(String n) {
        String val;

        if (StringUtils.isBlank(n)) {
            return null;
        }
        val = n;

        for (PayType payType: values()) {
            if (payType.getValue().equals(val))
                return payType;
        }

        for (PayType payType: values()) {
            if (payType.getDesc().equals(val))
                return payType;
        }

        return null;
    }
}
